/**
 入驻小区
 **/
(function (vc) {
    vc.extends({
        data: {
            adminRoomFeeInfo: {
                roomName: '',
                roomId: '',
                ownerId: '',
                ownerName: '',
                roomType: '',
                _currentTab: 'aRoomDetailRoomFee',
                condition: {
                    roomNum: '',
                    ownerName: '',
                }
            },
        },
        _initMethod: function () {
            vc.emit('communityRoomTree', 'initCommunityRoomTree', {
                callName: 'adminRoomFee'
            });
        },
        _initEvent: function () {
            vc.on('adminRoomFee', 'selectRoom', function (_param) {
                $that.adminRoomFeeInfo.ownerName = '';
                $that.adminRoomFeeInfo.ownerId = '';
                $that.adminRoomFeeInfo.roomId = _param.roomId;
                $that.adminRoomFeeInfo.roomName = _param.roomName;

                $that.adminRoomFeeInfo.condition.ownerName = '';
                $that.adminRoomFeeInfo.condition.roomNum = '';
                $that.listRoomInAdminRoomFee();
            });
            vc.on('adminRoomFee', 'notifyRoomByOwner', function (_room) {
                vc.copyObject(_room, $that.adminRoomFeeInfo);
                $that.adminRoomFeeInfo.roomId = _room.roomId;
                $that.adminRoomFeeInfo.roomName = _room.floorNum + "-" + _room.unitNum + "-" + _room.roomNum;
                $that.listRoomInAdminRoomFee();
            });

        },
        methods: {
            listRoomInAdminRoomFee: function () {
                let param = {
                    params: {
                        page: 1,
                        row: 1,
                        roomId: $that.adminRoomFeeInfo.roomId,
                    }
                };
                if ($that.adminRoomFeeInfo.condition.roomNum) {
                    param.params.flag = '1';
                    param.params.roomNum = $that.adminRoomFeeInfo.condition.roomNum;
                    param.params.roomId = '';
                    $that.adminRoomFeeInfo.roomName = "";
                    $that.adminRoomFeeInfo.ownerName = "";
                    $that.adminRoomFeeInfo.ownerId = "";
                    $that.adminRoomFeeInfo.roomId = "";

                }
                //发送get请求
                vc.http.apiGet('/room.queryAdminRoom',
                    param,
                    function (json, res) {
                        let _json = JSON.parse(json);
                        vc.copyObject(_json.data[0], $that.adminRoomFeeInfo);
                        $that.changeTab($that.adminRoomFeeInfo._currentTab);

                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                    }
                );
            },
            //查询
            _queryAdminRoomFeeMethod: function () {
                // 关闭查询组件
                $that.listRoomInAdminRoomFee();
            },
            //重置
            _resetAdminRoomFeeMethod: function () {

                // 关闭查询组件
                vc.emit('inputSearchRoomInfo', 'close', {});
                vc.emit('inputSearchRoomByOwner', 'close', {});
                $that.adminRoomFeeInfo.roomNum = "";
                $that.adminRoomFeeInfo.ownerName = "";
                $that.adminRoomFeeInfo.ownerId = "";
                $that.adminRoomFeeInfo.condition.ownerName = '';
                $that.adminRoomFeeInfo.condition.roomNum = '';
                $that.changeTab($that.adminRoomFeeInfo._currentTab);
            },

            changeTab: function (_tab) {
                $that.adminRoomFeeInfo._currentTab = _tab;
                vc.emit(_tab, 'switch', {
                    ownerId: $that.adminRoomFeeInfo.ownerId,
                    ownerName: $that.adminRoomFeeInfo.ownerName,
                    roomId: $that.adminRoomFeeInfo.roomId,
                    roomName: $that.adminRoomFeeInfo.roomName,
                })
            },
        }
    });
})(window.vc);